package com.example.myfoodrecipe.util

import androidx.room.TypeConverter
import com.example.myfoodrecipe.data.model.FoodRecipe
import com.example.myfoodrecipe.data.model.Result
import com.google.gson.Gson

class RecipeTypeConverter {
    //foodRecipe -> String
    @TypeConverter
    fun foodRecipeToString(recipe: FoodRecipe): String{
        return Gson().toJson(recipe)
    }

    @TypeConverter
    fun stringToFoodRecipe(string: String): FoodRecipe{
        return Gson().fromJson(string,FoodRecipe::class.java)
    }

    @TypeConverter
    fun resToStr(recipe: Result): String{
        return Gson().toJson(recipe)
    }

    @TypeConverter
    fun strToRes(str: String): Result{
        return Gson().fromJson(str,Result::class.java)
    }
}